package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.AnnouncementMapper;
import com.tanhua.model.domain.Announcement;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class AnnouncementApiImpl implements AnnouncementApi {
    @Autowired
    private AnnouncementMapper announcementMapper;

    @Override
    public Page<Announcement> findAnnouncement(Integer page, Integer pagesize) {
        Page<Announcement> pages = new Page<>(page,pagesize);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.select().orderByDesc("updated");
        return announcementMapper.selectPage(pages, queryWrapper);
    }

    // 查询多少条
    @Override
    public Long count() {
        Long count = Long.valueOf(announcementMapper.selectCount(null));
        return count;
    }
}
